//专利奖许可种类
var license_type_arr = [
        {"Name":"独占许可","Value":"独占许可","Expand":"","id":"extModel11687-1","Index":0}
        ,{"Name":"排他许可","Value":"排他许可","Expand":"","id":"extModel11687-2","Index":1}
        ,{"Name":"普通许可","Value":"普通许可","Expand":"","id":"extModel11687-3","Index":2}
    ];
//任务来源
var task_source_arr = [
    {"Name":"A.国家（部门、地方）计划（基金）","Value":"A","Expand":"","id":"extModel2613-1","Index":0}
    ,{"Name":"B.国家电网公司计划","Value":"B","Expand":"","id":"extModel2613-2","Index":1}
    ,{"Name":"C.部、委及省、市、自治区计划","Value":"C","Expand":"","id":"extModel2613-3","Index":2}
    ,{"Name":"D.基金资助","Value":"D","Expand":"","id":"extModel2613-4","Index":3}
    ,{"Name":"E.省公司计划","Value":"E","Expand":"","id":"extModel2613-5","Index":4}
    ,{"Name":"F.其他单位委托","Value":"F","Expand":"","id":"extModel2613-6","Index":5}
    ,{"Name":"G.自选","Value":"G","Expand":"","id":"extModel2613-7","Index":6}
    ,{"Name":"H.其他","Value":"H","Expand":"","id":"extModel2613-8","Index":7}
    ];
//完成人——角色
var role_arr = [
    {"Name":"负责人","Value":"100","Expand":"","id":"extModel3085-1","Index":0}
    ,{"Name":"完成人","Value":"1","Expand":"","id":"extModel3085-2","Index":1}
];

var box_index;
//layui
var js_layui;
function layui_pass_value(layui){
    js_layui = layui
}
/**
 * 等级 单位
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td066_open_selection_box(fieldId,main_table_id,index_value,assignmentField) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td066_selectionDivID" style="height: 95%">'
            +'<!--内容-->'
            +'<form class="layui-form" id="td066_selectionFormID" style="height: 100%">'
                +'<!--搜索框-->'
                +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
                    +'<div class="layui-input-inline">'
                        +'<label class="layui-form-label">名称</label>'
                        +'<div class="layui-input-inline">'
                            +'<input type="text" id="td066_tdi323" class="layui-input"/>'
                        +'</div>'
                    +'</div>'
                    +'<div class="layui-input-inline">'
                        +'<label class="layui-form-label">单位全称</label>'
                        +'<div class="layui-input-inline">'
                            +'<input type="text" id="td066_tdi402" class="layui-input"/>'
                        +'</div>'
                    +'</div>'
                    +'<button type="button" class="layui-btn layui-btn-normal" onclick="td066_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
                +'</div>'
                +'<table class="layui-hide" id="td066" lay-filter="td066"></table>'
                +'<!--操作按钮-->'
                +'<div class="layui-form-item" style="margin-bottom: 0px;">'
                    +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
                        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td066'+'\''+','+'\''+'tdi323'+'\''+','+'\''+'genTd066'+'\''+','+'\''+'genid'+'\''+','+'\''+assignmentField+'\''+')">选择</button>'
                        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
                    +'</div>'
                +'</div>'
            +'</form>'
        +'</div>'
        ,success: function(){
            /*单位*/
            js_layui.table.render({
                elem: '#td066'
                ,url:'/query/selectUnit'
                ,title: '单位'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi323', title:'名称',width:150,fixed: 'left'}
                        ,{field:'tdi402', title:'单位全称'}
                        ,{field:'tdi324', title:'所在地'}
                        ,{field:'tdi106', title:'联系人'}
                        /*,{field:'tdi729', title:'排序'}
                        ,{field:'tdi401', title:'类型'}*/
                    ]
                ]
                ,height:'full-380'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 单位检索
 */
window.td066_search = function () {
    var tdi323 = $("#td066_tdi323").val();
    var tdi402 = $("#td066_tdi402").val();
    js_layui.table.reload('td066',{
        method:'get',
        where:{"tdi323":tdi323,"tdi402":tdi402}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};

/**
 * 等级
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 *  @param isCondition  是否加条件
 * */
function td039_open_selection_box(fieldId,main_table_id,index_value,isCondition) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td039_selectionDivID" style="height: 95%">'
            +'<!--内容-->'
            +'<form class="layui-form" id="td039_selectionFormID" style="height: 100%">'
                +'<table class="layui-hide" id="td039" lay-filter="td039"></table>'
                +'<!--操作按钮-->'
                +'<div class="layui-form-item" style="margin-bottom: 0px;">'
                    +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
                        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td039'+'\''+','+'\''+'tdi259'+'\''+','+'\''+'genTd039'+'\''+','+'\''+'tdi258'+'\''+')">选择</button>'
                        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
                    +'</div>'
                +'</div>'
            +'</form>'
        +'</div>'
        ,success: function(){
            /*等级*/
            js_layui.table.render({
                elem: '#td039'
                ,url:'/queryInformation/genTd039QueryPage'
                ,title: '等级'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi258', title:'编码',hide:true}
                        ,{field:'tdi259', title:'名称'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}

/**
 * 电力科技成果分类与代码
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td034_open_selection_box(fieldId,main_table_id,index_value,isCondition) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td034_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td034_selectionFormID" style="height: 100%">'
        +'<!--搜索框-->'
        +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">名称</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td034_tdi236" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<button type="button" class="layui-btn layui-btn-normal" onclick="td034_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
        +'</div>'
        +'<table class="layui-hide" id="td034" lay-filter="td039"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td034'+'\''+','+'\''+'tdi236'+'\''+','+'\''+'genTd034'+'\''+','+'\''+'tdi233'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*电力科技成果分类与代码*/
            js_layui.table.render({
                elem: '#td034'
                ,url:'/queryInformation/genTd034QueryPage'
                ,title: '电力科技成果分类与代码'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi233', title:'编码'}
                        ,{field:'tdi236', title:'名称'}
                        ,{field:'tdi288', title:'描述'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 单位检索
 */
window.td034_search = function () {
    var tdi236 = $("#td034_tdi236").val();
    js_layui.table.reload('td034',{
        method:'get',
        where:{"tdi236":tdi236}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};

/**
 * 经济行业领域
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function economic_sector_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td066_selectionDivID" style="height: 95%">'
            +'<!--内容-->'
            +'<form class="layui-form" id="economicSector_selectionFormID" style="height: 100%">'
                +'<!--搜索框-->'
                +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
                    +'<div class="layui-input-inline">'
                        +'<label class="layui-form-label">编码</label>'
                        +'<div class="layui-input-inline">'
                            +'<input type="text" id="economicSector_id" class="layui-input"/>'
                        +'</div>'
                    +'</div>'
                    +'<button type="button" class="layui-btn layui-btn-normal" onclick="economic_sector_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
                    +'</div>'
                +'<table class="layui-hide" id="economicSector" lay-filter="economicSector"></table>'
                +'<!--操作按钮-->'
                +'<div class="layui-form-item" style="margin-bottom: 0px;">'
                    +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
                        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'economicSector'+'\''+','+'\''+'name'+'\''+','+'\''+'economicSector'+'\''+','+'\''+'id'+'\''+')">选择</button>'
                        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
                    +'</div>'
                +'</div>'
            +'</form>'
        +'</div>'
        ,success: function(){
            /*经济行业领域*/
            js_layui.table.render({
                elem: '#economicSector'
                ,url:'/queryInformation/economicSectorQueryPage'
                ,title: '经济行业领域'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'id', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'id', title:'编码',width:150,fixed: 'left'}
                        ,{field:'name', title:'名称'}
                        ,{field:'order', title:'排序'}
                    ]
                ]
                ,height:'full-380'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 经济行业领域检索
 */
window.economic_sector_search = function () {
    var id = $("#economicSector_id").val();
    js_layui.table.reload('economicSector',{
        method:'get',
        where:{"id":id}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};


/**
 * 组别
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td126_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td126_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td126_selectionFormID" style="height: 100%">'
        +'<table class="layui-hide" id="td126" lay-filter="td126"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td126'+'\''+','+'\''+'tdi705'+'\''+','+'\''+'genTd126'+'\''+','+'\''+'tdi706'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*组别*/
            js_layui.table.render({
                elem: '#td126'
                ,url:'/query/selectGroup'
                ,title: '组别'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi706', title:'值'}
                        ,{field:'tdi705', title:'名称'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}

/**
 * 部门
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function department_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="department_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="department_selectionFormID" style="height: 100%">'
        +'<table class="layui-hide" id="department" lay-filter="department"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'department'+'\''+','+'\''+'name'+'\''+','+'\''+'department'+'\''+','+'\''+'genid'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*单位*/
            js_layui.table.render({
                elem: '#department'
                ,url:'/query/selectDepartment'
                ,title: '部门'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'id', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'name', title:'名称'}
                        ,{field:'type', title:'类型'}
                        ,{field:'number', title:'编号'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 人员
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 *  @param assignmentField  选择框中被选择的表中要赋值字段 id,id;name,name
 * */
function td16_open_selection_box(fieldId,main_table_id,index_value,assignmentField) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td16_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td16_selectionFormID" style="height: 100%">'
        +'<!--搜索框-->'
        +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">姓名</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td16_tdi106" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">公司/单位</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td16_tdi105" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<button type="button" class="layui-btn layui-btn-normal" onclick="td16_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
        +'</div>'
        +'<table class="layui-hide" id="td16" lay-filter="td066"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td16'+'\''+','+'\''+'tdi106'+'\''+','+'\''+'genTd16'+'\''+','+'\''+'genid'+'\''+','+'\''+assignmentField+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*单位*/
            js_layui.table.render({
                elem: '#td16'
                ,url:'/query/selectUser'
                ,title: '单位'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi106', title:'姓名',width:150,fixed: 'left'}
                        ,{field:'tdi105', title:'公司/单位',hide:true}
                        ,{field:'tdi323', title:'公司/单位'}
                        /*,{field:'tdi691', title:'部门'}*/
                    ]
                ]
                ,height:'full-380'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 单位检索
 */
window.td16_search = function () {
    var tdi106 = $("#td16_tdi106").val();
    var tdi105 = $("#td16_tdi105").val();
    js_layui.table.reload('td16',{
        method:'get',
        where:{"tdi323":tdi106,"tdi105":tdi105}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};

/**
 * 奖项名称
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td038_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td038_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td038_selectionFormID" style="height: 100%">'
        +'<!--搜索框-->'
        +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">编码</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td038_tdi256" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">名称</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td038_tdi105" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<button type="button" class="layui-btn layui-btn-normal" onclick="td038_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
        +'</div>'
        +'<table class="layui-hide" id="td038" lay-filter="td038"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td038'+'\''+','+'\''+'tdi257'+'\''+','+'\''+'genTd038'+'\''+','+'\''+'tdi257'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*单位*/
            js_layui.table.render({
                elem: '#td038'
                ,url:'/queryInformation/genTd038QueryPage'
                ,title: '单位'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi256', title:'编码',width:150,fixed: 'left'}
                        ,{field:'tdi257', title:'名称'}
                    ]
                ]
                ,height:'full-380'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 单位检索
 */
window.td038_search = function () {
    var tdi256 = $("#td038_tdi256").val();
    var tdi257 = $("#td038_tdi257").val();
    js_layui.table.reload('td038',{
        method:'get',
        where:{"tdi256":tdi256,"tdi257":tdi257}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};

/**
 * 知识产权
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 *  @param assignmentField  选择框中被选择的表中要赋值字段 id,id;name,name
 * */
function td040_open_selection_box(fieldId,main_table_id,index_value,assignmentField) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td040_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td040_selectionFormID" style="height: 100%">'
        +'<!--搜索框-->'
        +'<div class="layui-inline" style="margin-bottom: 5px;margin-top: 5px">'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">名称</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td040_tdi263" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<div class="layui-input-inline">'
        +'<label class="layui-form-label">授权号</label>'
        +'<div class="layui-input-inline">'
        +'<input type="text" id="td040_tdi265" class="layui-input"/>'
        +'</div>'
        +'</div>'
        +'<button type="button" class="layui-btn layui-btn-normal" onclick="td040_search()"><i class="layui-icon layui-icon-search"></i>检索</button>'
        +'</div>'
        +'<table class="layui-hide" id="td040" lay-filter="td040"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td040'+'\''+','+'\''+'tdi263'+'\''+','+'\''+'genTd040'+'\''+','+'\''+'genid'+'\''+','+'\''+assignmentField+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*单位*/
            js_layui.table.render({
                elem: '#td040'
                ,url:'/queryInformation/genTd040QueryPage'
                ,title: '单位'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi260', title:'类别',width:150,fixed: 'left'}
                        ,{field:'tdi263', title:'名称'}
                        ,{field:'tdi264', title:'国家（地区）'}
                        ,{field:'tdi265', title:'授权号'}
                        ,{field:'tdi266', title:'授权日期'}
                        ,{field:'tdi267', title:'证书编号'}
                        ,{field:'tdi270', title:'发明专利有效状态'}
                    ]
                ]
                ,height:'full-380'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}
/**
 * 单位检索
 */
window.td040_search = function () {
    var tdi263 = $("#td040_tdi263").val();
    var tdi265 = $("#td040_tdi265").val();
    js_layui.table.reload('td040',{
        method:'get',
        where:{"tdi263":tdi263,"tdi265":tdi265}
        ,page: {
            curr: 1//重新从第 1 页开始
        }
    });
};

/**
 * 组别
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td041_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td041_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td041_selectionFormID" style="height: 100%">'
        +'<table class="layui-hide" id="td041" lay-filter="td041"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td041'+'\''+','+'\''+'tdi261'+'\''+','+'\''+'genTd041'+'\''+','+'\''+'tdi261'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*组别*/
            js_layui.table.render({
                elem: '#td041'
                ,url:'/queryInformation/genTd041QueryPage'
                ,title: '专利类型'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi261', title:'编码'}
                        ,{field:'tdi262', title:'名称'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}

/**
 * 组别
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 * */
function td18_open_selection_box(fieldId,main_table_id,index_value) {
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['50%', '70%'] 	//宽  高
        ,title: '浏览'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 选择框——弹框 -->'
        +'<div id="td18_selectionDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="td18_selectionFormID" style="height: 100%">'
        +'<table class="layui-hide" id="td18" lay-filter="td18"></table>'
        +'<!--操作按钮-->'
        +'<div class="layui-form-item" style="margin-bottom: 0px;">'
        +'<div class="layui-input-block" style="margin-left: calc(100% - 180px);">'
        +'<button type="button" class="layui-btn" onclick="selection_submit('+'\''+fieldId+'\''+','+'\''+main_table_id+'\''+','+'\''+index_value+'\''+','+'\''+'td18'+'\''+','+'\''+'tdi131'+'\''+','+'\''+'genTd18'+'\''+','+'\''+'tdi183'+'\''+')">选择</button>'
        +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
        +'</div>'
        +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            /*组别*/
            js_layui.table.render({
                elem: '#td18'
                ,url:'/queryInformation/genTd18QueryPage'
                ,title: '专利类型'
                ,limits:[10,20,30]
                ,cols: [
                    [
                        {type: 'radio', fixed: 'left'}
                        ,{field:'genid', title:'序号', sort: true, type:'numbers', width: 60,fixed: 'left'}
                        ,{field:'tdi167', title:'类型'}
                        ,{field:'tdi131', title:'名称'}
                    ]
                ]
                ,height:'full-330'
                ,page: true
                ,done : function(){
                    $('th').css({
                        'background-color': '#009688', 'color': '#fff','font-weight':'bold',
                    })
                }
            });
            js_layui.form.render();
        }
    });
}

/**
 *  公用选择框选择(AJAX方式)
 *  @param fieldId  操作字段
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param index_value  选择框对应的主表的索引值
 *  @param GenId  选择框中被选择的表
 *  @param GenXsFielId  选择框中被选择的表中要展示的内容
 *  @param Bean  选择框中被选择的表对应的实体
 *  @param GenSaveFielId  选择框中被选择的表中要保存字段
 *  @param assignmentField  选择框中被选择的表中要赋值字段 id,id;name,name
 */
window.selection_submit = function (fieldId, main_table_id, index_value, GenId, GenXsFielId, Bean, GenSaveFielId,assignmentField) {
    var rowData = js_layui.table.checkStatus(GenId);
    var data = rowData.data;
    if(data.length == 0){
        js_layui.layer.alert("请选择一条记录！",{icon :5});
    } else {
        if(main_table_id != null && main_table_id != "" && main_table_id != undefined && main_table_id != "undefined"){
            //父级表格的数据
            var oldData = js_layui.table.cache[main_table_id];
            var index = oldData.findIndex(function(item) {
                return item.indexValue == index_value;
            });
            oldData[index][fieldId] = data[0][GenSaveFielId];
            oldData[index][Bean] = data[0];
            if(assignmentField != null && assignmentField != ""){
                var assignmentArr = assignmentField.split(";")
                for(var i= 0;i<assignmentArr.length;i++){
                    var files = assignmentArr[i].split(",")
                    if(assignmentArr[i].indexOf(".") != -1){
                        var file1s = files[1].split(".")
                        var file0s = files[0].split(".")
                        if(files[1].indexOf(".") != -1 && files[0].indexOf(".") != -1){
                            if(data[0][file0s[0]] != null){
                                var xm = new Object();
                                xm[file1s[1]] = data[0][file0s[0]][file0s[1]];
                                oldData[index][file1s[0]] = xm;
                            }
                        }else if(files[1].indexOf(".") != -1){
                            var xm = new Object();
                            xm[file1s[1]] = data[0][files[0]];
                            oldData[index][file1s[0]] = xm;
                        }else if(files[0].indexOf(".") != -1){
                            if(data[0][file0s[0]] != null) {
                                oldData[index][files[1]] = data[0][file0s[0]][file0s[1]];
                            }
                        }
                    }else{
                        oldData[index][files[1]] = data[0][files[0]];
                    }
                }
            }
            //重新加载父级表格
            js_layui.table.reload(main_table_id,{
                data : oldData
            });
        }else{
            $("[name='"+fieldId+"']").val(data[0][GenSaveFielId]);
            $("[name='"+fieldId+"Name']").val(data[0][GenXsFielId]);
        }
    }
    js_layui.layer.close(box_index);
    return false;
};
/**
 * 公用关闭弹框(AJAX方式)
 */
window.close_selection_box = function () {
    js_layui.layer.close(box_index);
    return false;
};

var js_subTableNumIdArr = [];
/**
 * 表格上传文件
 *  @param type  类型 .jpg, .bmp
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param subTableNumIdArr 表及索引值
 * */
function table_upload(type,main_table_id,subTableNumIdArr) {
    js_subTableNumIdArr = subTableNumIdArr;
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['380px', '200px'] 	//宽  高
        ,title: '上传文件'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:'<!-- 导入模板 -->'
        +'<div class="modal fade" id="importDiv1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">'
            +'<div class="modal-dialog" role="document">'
                +'<div class="modal-content">'
                    +'<div class="modal-body">'
                        +'<form id="importForm" class="layui-form" enctype="multipart/form-data">'
                            +'<div title="Excel导入操作" style="margin-left: 105px; padding: 5px">'
                                +'<input id="file" name="file" type="file" style="margin-bottom: 20px" accept="'+type+'"/>'
                            +'</div>'
                        +'</form>'
                        +'<div align="center">'
                            +'<button class="layui-btn layui-btn-blue" onclick="uploadBtn1('+'\''+main_table_id+'\''+','+'\''+type+'\''+')">导入</button>'
                            +'&emsp;&emsp;'
                            +'<button class="layui-btn layui-btn-primary" onclick="close_selection_box()">取消</button>'
                        +'</div>'
                    +'</div>'
                +'</div>'
            +'</div>'
        +'</div>'
        ,success: function(){
            $("#file").val(null)
            js_layui.form.render();
        }
    });
}
function toUnicode(theString) {
    /*var unicodeString = '';
    for (var i = 0; i < theString.length; i++) {
        var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase();
        while (theUnicode.length < 4) {
            theUnicode = '0' + theUnicode;
        }
        theUnicode = '\\u' + theUnicode;
        unicodeString += theUnicode;
    }*/
    return theString;
}
/**
 * 把数据传到后台
 */
window.uploadBtn1 = function(main_table_id,type){
    let file=$("#file").val();
    if(file == null || file == "") {
        js_layui.layer.alert("请选择上传文件",{icon :5});
        return;
    }else{
        let filename=file.substr(file.lastIndexOf("."));
        filename = filename.toLowerCase()
        type = type.toLowerCase()
        if(type.indexOf(filename) == -1){
            js_layui.layer.alert("请上传限定格式的文件",{icon :5});
            return;
        }
    }
    var formData = new FormData($("#importForm")[0]);
    $.ajax({
        url: '/ueditor/upload' ,
        type: 'post',
        data: formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (res) {
            if (res.code == 0) {
                var oldData = js_layui.table.cache[main_table_id];
                var index = js_subTableNumIdArr.findIndex(function(item) {
                    return item.tableId === main_table_id;
                });
                console.log(index);
                var data = res.data;
                var arr = {
                    "indexValue":js_subTableNumIdArr[index].indexValue
                    ,"id": data.id
                    ,"FileName": data.FileName
                    ,"Url": toUnicode(data.Url)
                    ,"Date": data.Date
                    ,"Index": oldData.length
                };
                js_subTableNumIdArr[index].indexValue++;
                oldData.push(arr);
                js_layui.table.reload(main_table_id,{
                    data:oldData
                });
                js_layui.layer.close(box_index);
            }
        },
        error: function (data) {
            toastr.error("导入失败！");
        }
    });
};
//根据不同action上传图片和附件
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
UE.Editor.prototype.getActionUrl = function(action) {
    if (action == 'uploadimage') {
        return '/ueditor/upload/1433';
    } else if (action == 'uploadfile') {
        return '${pageContext.request.contextPath}/upload/uploadfile';
    } else {
        return this._bkGetActionUrl.call(this, action);
    }
};
window.UEDITOR_CONFIG.toolbars = [[
    'source', //源代码
    //'anchor', //锚点
    'undo', //撤销
    'redo', //重做
    'bold', //加粗
    'italic', //斜体
    'indent', //首行缩进
    'underline', //下划线
    'strikethrough', //删除线
    'subscript', //下标
    'fontborder', //字符边框
    'superscript', //上标
    '|',
    'forecolor', //字体颜色
    'backcolor', //背景色
    'background', //背景
    '|',
    'formatmatch', //格式刷
    'removeformat', //清除格式
    'pasteplain', //纯文本粘贴模式
    'selectall', //全选
    //'template', //模板
    'preview', //预览
    'print', //打印
    'cleardoc', //清空文档
    'fontfamily', //字体
    'fontsize', //字号
    'paragraph', //段落格式
    'searchreplace', //查询替换
    'time', //时间
    'date', //日期
    'customstyle', //自定义标题
    'autotypeset', //自动排版

    'justifyleft', //居左对齐
    'justifyright', //居右对齐
    'justifycenter', //居中对齐
    'justifyjustify', //两端对齐
    'imagecenter', //居中
    'insertorderedlist', //有序列表
    'insertunorderedlist', //无序列表
    'directionalityltr', //从左向右输入
    'directionalityrtl', //从右向左输入
    'rowspacingtop', //段前距
    'rowspacingbottom', //段后距
    'lineheight', //行间距
    'horizontal', //分隔线
    'pagebreak', //分页
    '|',
    'touppercase', //字母大写
    'tolowercase', //字母小写

    '|',
    'inserttable', //插入表格
    'insertrow', //前插入行
    'insertcol', //前插入列
    'mergeright', //右合并单元格
    'mergedown', //下合并单元格
    'deleterow', //删除行
    'deletecol', //删除列
    'splittorows', //拆分成行
    'splittocols', //拆分成列
    'splittocells', //完全拆分单元格
    'deletecaption', //删除表格标题
    'inserttitle', //插入标题
    'mergecells', //合并多个单元格
    'deletetable', //删除表格
    'insertparagraphbeforetable', //"表格前插入行"
    'edittable', //表格属性
    'edittd', //单元格属性
    '|',
    'emotion', //表情
    'spechars', //特殊字符
    'help', //帮助
    'fullscreen', //全屏
    //'blockquote', //引用
    //'insertcode', //代码语言
    //'snapscreen', //截图
    'simpleupload', //单图上传
    'insertimage', //多图上传
    //'map', //Baidu地图
    //'gmap', //Google地图
    //'insertvideo', //视频
    //'insertframe', //插入Iframe
    //'imagenone', //默认
    //'imageleft', //左浮动
    //'imageright', //右浮动
    //'attachment', //附件
    //'wordimage', //图片转存
    //'unlink', //取消链接
    //'link', //超链接
    //'webapp', //百度应用
    //'scrawl', //涂鸦
    //'music', //音乐
    //'drafts', // 从草稿箱加载
    //'charts', // 图表
    //'edittip ', //编辑提示
]];

window.UEDITOR_CONFIG.zIndex = 99999999;
window.UEDITOR_CONFIG.autoHeightEnabled = false;
/**
 * 表格上传文件
 *  @param type  类型 .jpg, .bmp
 *  @param main_table_id  选择框对应的主表 （不传则为input框）
 *  @param subTableNumIdArr 表及索引值
 * */
function table_ueditor(main_table_id,subTableNumIdArr) {
    js_subTableNumIdArr = subTableNumIdArr;
    box_index = js_layui.layer.open({
        type: 1 					//Page层类型
        ,area: ['60%', '80%'] 	//宽  高
        ,title: '上传文件'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 				//允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content:
        '<!-- 选择框——弹框 -->'
        +'<div id="ueditorDivID" style="height: 95%">'
        +'<!--内容-->'
        +'<form class="layui-form" id="ueditorFormID" style="height: 100%">'
            +'<textarea id="html" style="height: calc(100% - 90px);width: calc(100% - 2px)"></textarea>'
            +'<!--操作按钮-->'
            +'<div style="margin-left: calc(100% - 180px);">'
                +'<button type="button" class="layui-btn" onclick="ueditor_Btn('+'\''+main_table_id+'\''+')">上传</button>'
                +'<button type="button" class="layui-btn" onclick="close_selection_box()">关闭</button>'
            +'</div>'
        +'</form>'
        +'</div>'
        ,success: function(){
            UE.getEditor('html');
            js_layui.form.render();
        }
        ,end: function () {//无论是确认还是取消，只要层被销毁了，end都会执行，不携带任何参数。layer.open关闭事件
            UE.getEditor('html').destroy();
        }
    });
}

/**
 * 把数据传到后台
 */
window.ueditor_Btn = function(main_table_id){
    var arr = [];
    arr.push(UE.getEditor('html').getContent());
    console.log(arr.join("\n"));

    //是否有内容
    var contents = UE.getEditor('html').hasContents();
    if (contents) {
        //window.location.href = "/ueditor/exportWord?str="+arr.join("\n")
        $.ajax({
            url: '/ueditor/exportWord?str='+arr.join("\n"),
            type: 'post',
            //data: {str: arr.join("\n")},
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (res) {
                if (res.code == 0) {
                    var oldData = js_layui.table.cache[main_table_id];
                    var index = js_subTableNumIdArr.findIndex(function (item) {
                        return item.tableId === main_table_id;
                    });
                    console.log(index);
                    var data = res.data;
                    var arr = {
                        "indexValue": js_subTableNumIdArr[index].indexValue
                        , "id": data.id
                        , "FileName": data.FileName
                        , "Url": toUnicode(data.Url)
                        , "Date": data.Date
                        , "Index": oldData.length
                    };
                    js_subTableNumIdArr[index].indexValue++;
                    oldData.push(arr);
                    js_layui.table.reload(main_table_id, {
                        data: oldData
                    });
                    js_layui.layer.close(box_index);
                }
            },
            error: function (res) {
                toastr.error("导入失败！");
            }
        });
    }else{
        js_layui.layer.alert("请录入信息",{icon :5});
    }
};



/**
 * 清除输入框的内容
 */
function clearValue(id) {
    $("[name='"+id+"']").val("")
    $("[name='"+id+"Name"+"']").val("")
}















